<extend name="./Public/Home/master.html" />
<block name="content">
	</div>
	<!--导航结束-->
	<div class="clear"></div>

	</div>
	<!--头部结束-->
	<!--中间开始-->
	<div id="content">
		<form action="{:u('home/Accounts/index')}" method="post">
			<div class="car main">
				<?php if(isset($_SESSION['cart'])){ ?>
				<div class="carshop">
					<div class="cartitle">
						<div class="carcheck">
							<div class="checkbox ">
								<span class="check checkon" id="allcheck" style="border:none;margin-top: 0"></span>
							</div>
							全选</div>
						<div class="carname">商品名称</div>
						<div class="carmoney">单价</div>
						<div class="carnum">数量</div>
						<div class="carcount">小计</div>
						<div class="carhandle">操作</div>
					</div>
					<?php foreach($cartData['goods'] as $k=>$v){ ?>
					<div class="shopcontent">
						<div class="shopcheck">
							<div class="checkbox">
								<input type="checkbox" checked="checked" name='checkbox' class="checkhide"/>
								<span class="check checkon" style="margin-top: 0"></span>
							</div>
						</div>
						<div class="shopname">
							<div class="carimg">
								<a href=""><img src="__PUBLIC__/Home/images/car.jpg"/></a>
							</div>
							<p>
								<a href="#">{$v['name']}</a>
								<span></span>
							</p>
						</div>
						<div class="shopmoney">{$v['price']}元</div>
						<div class="shopnum">

							<a href="javascript:;" class="num_l">-</a>
							<input type="text" value="{$v['num']}" />
							<a href="javascript:;" class="num_r" sid="{$k}">+</a>
						</div>
						<div class="shopcount">{$v['total']}元</div>
						<div class="shophandle"><span sid="{$k}">x</span></div>
					</div>
					<?php } ?>
				</div>
				<div class="jiesuan">
					<div class="jixu"><a href="">继续购物</a></div>
					<div class="gongji">共计<span>{$cartData['total_rows']}</span>件商品</div>
					<div class="heji">合计<span>{$cartData['total']}</span></div>
					<div class="gou"><input type="submit" value="去结算"/></div>

				</div>
				<?php }else{  ?>
				<div>
					购物车空空，<a href="">继续购物</a>
				</div>
				<?php } ?>
			</div>
			<script>
				$(function(){

				});
			</script>
		</form>
	</div>
	</div>
	<script>
		$('.shopcheck .checkbox span').click(function(){
			//alert();
			var hj = parseInt($('.heji span').text());
			var gj = parseInt($('.gongji span').text());
			//alert(hj);
			var total =parseInt($(this).parents().siblings('.shopcontent .shopcount').text());
			if($(this).hasClass('checkon')){
				//alert(total);
				var newhj= hj-total;
				var newgj=gj-parseInt($(this).parents().siblings('.shopnum').children('input').val());
				//alert(newhj);
				$('.heji span').text(newhj);
				$('.gongji span').text(newgj);
			}else{
				var newgj=gj +parseInt($(this).parents().siblings('.shopnum').children('input').val());
				var newhj= hj+total;
				$('.heji span').text(newhj);
				$('.gongji span').text(newgj);
			}
		});

		//点击全选与取消
		$('.carcheck .checkbox span').click(function(){
			//alert(hj);
			//alert(1);
			if($(this).hasClass('checkon')){
				$('.heji span').text(0);
				$('.gongji span').text(0);
			}else{
				var hj="{$_SESSION['cart']['total']}";
				//alert(hj);
				var gj="{$_SESSION['cart']['total_rows']}";

				$('.heji span').text(hj);
				$('.gongji span').text(gj);
			}


		});





	</script>


</block>
